#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
  vector<int> twoSum(vector<int> &numbers, int target) {

    // codes

    vector<int> result(2, -1);

    int lo = 0;
    int hi = numbers.size() - 1;

    while (lo < hi) {
      int sum = numbers[lo] + numbers[hi];

      if (sum > target) {
        hi--;
      } else if (sum == target) {
        result[0] = lo + 1;
        result[1] = hi + 1;
        break;
      } else {
        lo++;
      }
    }

    return result;
  }
};

void testcase01() {
  printf("\n%s\n", __FUNCTION__);
  vector<int> input;
  // 2,7,11,15
  input.push_back(2);
  input.push_back(7);
  input.push_back(11);
  input.push_back(15);
  int target = 9;

  vector<int> result;
  Solution so;

  result = so.twoSum(input, target);
  printf("result:[%d, %d]\n", result[0], result[1]);
}

int main() {
  // codes
  testcase01();
  return 0;
}
